package com.lh.iterator;


import java.util.Iterator;
import java.util.List;

//信息工程系
public class InfoCollegeIterator implements Iterator {


    List<Department> departmentList; //信息工程学院，它是以List的方式存放系
    int index = -1; //索引

    public InfoCollegeIterator(List<Department> departmentList) {
        this.departmentList = departmentList;
    }

    //判断List中还有没有下一个元素
    @Override
    public boolean hasNext() {

        if (index >= departmentList.size() - 1) {
            return false;
        } else {
            index += 1;
            return true;
        }
    }

    @Override
    public Object next() {
        return departmentList.get(index);
    }

    //删除默认空实现
    public void remove(){

    }
}
